import 'package:flutter/material.dart';

class WelcomeView extends StatelessWidget {
  final AnimationController animationController;

  const WelcomeView({Key? key, required this.animationController})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    final isSmallScreen = screenSize.width < 400 || screenSize.height < 700;
    
    final _firstHalfAnimation =
        Tween<Offset>(begin: Offset(1, 0), end: Offset(0, 0)).animate(
      CurvedAnimation(
        parent: animationController,
        curve: Interval(
          0.8,
          1.0,
          curve: Curves.fastOutSlowIn,
        ),
      ),
    );

    final _welcomeImageAnimation =
        Tween<Offset>(begin: Offset(4, 0), end: Offset(0, 0))
            .animate(CurvedAnimation(
      parent: animationController,
      curve: Interval(
        0.8,
        1.0,
        curve: Curves.fastOutSlowIn,
      ),
    ));

    final _welcomeTextAnimation =
        Tween<Offset>(begin: Offset(2, 0), end: Offset(0, 0))
            .animate(CurvedAnimation(
      parent: animationController,
      curve: Interval(
        0.8,
        1.0,
        curve: Curves.fastOutSlowIn,
      ),
    ));

    return SlideTransition(
      position: _firstHalfAnimation,
      child: Container(
        width: double.infinity,
        height: double.infinity,
        child: SafeArea(
          child: Padding(
            padding: EdgeInsets.symmetric(
              horizontal: isSmallScreen ? 20 : 40,
              vertical: isSmallScreen ? 20 : 40,
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                SlideTransition(
                  position: _welcomeImageAnimation,
                  child: Container(
                    width: isSmallScreen ? 240 : 300,
                    height: isSmallScreen ? 240 : 300,
                    decoration: BoxDecoration(
                      shape: BoxShape.circle,
                      gradient: LinearGradient(
                        begin: Alignment.topLeft,
                        end: Alignment.bottomRight,
                        colors: [
                          Color(0xffF8BBD9),
                          Color(0xffE879F9),
                          Color(0xffC084FC),
                        ],
                      ),
                      boxShadow: [
                        BoxShadow(
                          color: Color(0xffE879F9).withOpacity(0.4),
                          blurRadius: 30,
                          offset: Offset(0, 15),
                        ),
                      ],
                    ),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Icon(
                          Icons.favorite,
                          size: isSmallScreen ? 80 : 100,
                          color: Colors.white,
                        ),
                        SizedBox(height: isSmallScreen ? 15 : 20),
                        Text(
                          "💕",
                          style: TextStyle(fontSize: isSmallScreen ? 40 : 50),
                        ),
                      ],
                    ),
                  ),
                ),
                SizedBox(height: isSmallScreen ? 40 : 50),
                SlideTransition(
                  position: _welcomeTextAnimation,
                  child: Column(
                    children: [
                      Text(
                        "欢迎来到",
                        style: TextStyle(
                          fontSize: isSmallScreen ? 20 : 24,
                          color: Color(0xff6B7280),
                        ),
                        textAlign: TextAlign.center,
                      ),
                      SizedBox(height: isSmallScreen ? 8 : 10),
                      Text(
                        "我们的小宇宙",
                        style: TextStyle(
                          fontSize: isSmallScreen ? 28 : 32,
                          fontWeight: FontWeight.bold,
                          color: Color(0xff2D1B69),
                          letterSpacing: 2,
                        ),
                        textAlign: TextAlign.center,
                      ),
                      SizedBox(height: isSmallScreen ? 16 : 20),
                      Padding(
                        padding: EdgeInsets.symmetric(horizontal: isSmallScreen ? 20 : 40),
                        child: Text(
                          "在这里，记录属于你们的\n每一个美好瞬间",
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            fontSize: isSmallScreen ? 16 : 18,
                            color: Color(0xff6B7280),
                            height: 1.6,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}